package com.aia.prm.web.ria.app.ui.plan;

import com.aia.prm.domain.VOPlan;
import com.aia.prm.web.ria.app.PrmApplication;
import com.vaadin.data.Property;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.Component;
import com.vaadin.ui.Link;
import com.vaadin.ui.Table;

public class PlanList extends Table {
	PrmApplication app;
	PlanView view;

	PlanList(PrmApplication aapp, PlanView aview) {
		app = aapp;
		view = aview;
		setSizeFull();

		setColumnCollapsingAllowed(true);
		setColumnReorderingAllowed(true);

		setSelectable(true);
		setImmediate(true);
		addListener((Property.ValueChangeListener) view);
		
		addGeneratedColumn("link1", new ColumnGenerator() {
			public Component generateCell(Table source, Object itemId, Object columnId) {
				VOPlan p = (VOPlan) itemId;
				Link l = new Link();
				l.setResource(new ExternalResource("../platform/index.jsp?pid=" + p.getPL_ID()));
				l.setTargetName("_blank");
				l.setCaption("模板1");
				return l;
			}
		});
		addGeneratedColumn("link2", new ColumnGenerator() {
			public Component generateCell(Table source, Object itemId, Object columnId) {
				VOPlan p = (VOPlan) itemId;
				Link l = new Link();
				l.setResource(new ExternalResource("../simple/index.jsp?pid=" + p.getPL_ID()));
				l.setTargetName("_blank");
				l.setCaption("模板2");
				return l;
			}
		});
		
	}

}
